package com.project.weimi.dialog;

import com.project.weimi.R;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

public class CouponDialogNoExist extends Dialog implements 
	android.view.View.OnClickListener{

	private Context context;
	private TextView tv_title,tv_know;
	
	public CouponDialogNoExist(Context context, int themeResId) {
		super(context, themeResId);
		// TODO Auto-generated constructor stub
	}

	public CouponDialogNoExist(Context context) {
		super(context);
		this.context = context;
	}

	@SuppressWarnings("deprecation")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);  
		Window dialogWindow = getWindow();
		WindowManager manager = dialogWindow.getWindowManager();
		Display d = manager.getDefaultDisplay(); //获取屏幕宽高
		WindowManager.LayoutParams p = dialogWindow.getAttributes(); //获取对话框当前的参数值

//      dialogWindow.setGravity(Gravity.CENTER);
//      p.x = 100; // 新位置X坐标
//      p.y = 100; // 新位置Y坐标
//      p.width = 300; // 宽度
//      p.height = 300; // 高度
//      p.alpha = 0.7f; // 透明度
        
//      int height = (int) (d.getHeight() * 0.3);
		int width = (int) (d.getWidth() * 0.8);
		Log.i("aaa", "屏幕宽----"+d.getWidth()+";对话框宽===="+width);
		
		p.width = width; //将对话框宽度设置为屏幕宽度的0.8
		dialogWindow.setAttributes(p);
		setContentView(R.layout.dialog_coupon_noexist);
		initView();
	}
	
	private void initView(){
		tv_title = (TextView)findViewById(R.id.tv_title);
		tv_know = (TextView)findViewById(R.id.tv_know);
		tv_know.setOnClickListener(this);
	}
	
	@Override
	public void onClick(View v) {
		if(v.getId() == R.id.tv_know){
			this.dismiss();
		}
	}

	
}
